<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich">

<ui:composition template="/templates/template.xhtml">
	<ui:define name="body">
		<h:form id="newPlan">
			<a4j:keepAlive beanName="buildDefinitionsManager"/>

			<a4j:outputPanel ajaxRendered="true">
				<h:panelGrid columns="3">
					<h:outputText value="Wybierz istniejący plan "/>
					<h:selectOneMenu
							value="#{buildDefinitionsManager.chosenDefinition}"
							disabled="#{buildDefinitionsManager.editMode}">
						<f:selectItems
								value="#{buildDefinitionsManager.availableDefinitions}"/>
						<a4j:support event="onchange"
						             action="#{buildDefinitionsManager.choose}"/>
					</h:selectOneMenu>
					<h:panelGroup>
						<h:outputText value=" lub "/>
						<a4j:commandLink value="dodaj nowy" disabled="#{buildDefinitionsManager.editMode}"
						                 action="#{buildDefinitionsManager.prepareForNew}"/>
					</h:panelGroup>
				</h:panelGrid>

				<rich:panel id="panelDetails">
					<f:facet name="header">
						<h:outputText value="Dodaj/Edytuj plan"/>
					</f:facet>

					<rich:messages layout="list"/>

					<h:panelGrid columns="2" columnClasses="columnLabel,columnValue">
						<h:outputText value="Nazwa:"/>
						<h:outputText
								value="#{buildDefinitionsManager.chosenDefinition.name}"
								rendered="#{! buildDefinitionsManager.editMode}"/>
						<h:inputText id="nazwa"
						             value="#{buildDefinitionsManager.chosenDefinition.name}"
						             rendered="#{buildDefinitionsManager.editMode}" required="true"/>

						<h:outputText value="Cron:"/>
						<h:outputText
								value="#{buildDefinitionsManager.chosenDefinition.cronExpr}"
								rendered="#{! buildDefinitionsManager.editMode}"/>
						<h:inputText id="cron"
						             value="#{buildDefinitionsManager.chosenDefinition.cronExpr}"
						             rendered="#{buildDefinitionsManager.editMode}"/>

						<h:outputText value="URL do SVN:"/>
						<h:outputLink value="#{buildDefinitionsManager.chosenDefinition.repositoryURL}" target="_blank"
						              rendered="#{! buildDefinitionsManager.editMode}">
							<h:outputText value="#{buildDefinitionsManager.chosenDefinition.repositoryURL}"/>
						</h:outputLink>
						<h:inputText id="repoURL"
						             value="#{buildDefinitionsManager.chosenDefinition.repositoryURL}"
						             rendered="#{buildDefinitionsManager.editMode}" required="true"/>

						<h:outputText value="Checkout do"/>
						<h:outputText
								value="#{buildDefinitionsManager.chosenDefinition.workingCopy}"
								rendered="#{! buildDefinitionsManager.editMode}"/>
						<h:inputText id="wrokingCopy"
						             value="#{buildDefinitionsManager.chosenDefinition.workingCopy}"
						             rendered="#{buildDefinitionsManager.editMode}" required="true"/>

						<h:outputText value="Build command:"/>
						<h:outputText
								value="#{buildDefinitionsManager.chosenDefinition.buildCommand}"
								rendered="#{! buildDefinitionsManager.editMode}"/>
						<h:inputText id="buildCommand"
						             value="#{buildDefinitionsManager.chosenDefinition.buildCommand}"
						             rendered="#{buildDefinitionsManager.editMode}" required="true"/>

						<h:outputText value="Wymuś 'czysty build': "/>
						<h:selectBooleanCheckbox id="forceCleanBuild" disabled="#{! buildDefinitionsManager.editMode}"
						                         value="#{buildDefinitionsManager.chosenDefinition.forceCleanBuild}"/>

						<h:outputText value="Powiadom adresy e-mail:"/>
						<h:outputText
								value="#{buildDefinitionsManager.chosenDefinition.notifiedEmails}"
								rendered="#{! buildDefinitionsManager.editMode}"/>
						<h:inputText id="notifiedEmails"
						             value="#{buildDefinitionsManager.chosenDefinition.notifiedEmails}"
						             rendered="#{buildDefinitionsManager.editMode}"/>

						<h:outputText value="Powiadom numery gg:"/>
						<h:outputText
								value="#{buildDefinitionsManager.chosenDefinition.notifiedGG}"
								rendered="#{! buildDefinitionsManager.editMode}"/>
						<h:inputText id="notifiedGG"
						             value="#{buildDefinitionsManager.chosenDefinition.notifiedGG}"
						             rendered="#{buildDefinitionsManager.editMode}"/>

						<rich:spacer height="60px"/>

						<h:panelGrid columns="3">
							<a4j:commandLink
									action="#{buildDefinitionsManager.prepareForEdit}"
									value="Edytuj" rendered="#{! buildDefinitionsManager.editMode}"/>
							<a4j:commandButton
									action="#{buildDefinitionsManager.saveChanges}" value="Zapisz"
									rendered="#{buildDefinitionsManager.editMode}"/>

							<h:outputText value="lub"/>

							<a4j:commandButton action="#{buildDefinitionsManager.delete}"
							                   value="Usuń" rendered="#{! buildDefinitionsManager.editMode}"/>
							<a4j:commandLink action="#{buildDefinitionsManager.cancel}"
							                 immediate="true" value="Anuluj"
							                 rendered="#{buildDefinitionsManager.editMode}"/>

						</h:panelGrid>

					</h:panelGrid>
				</rich:panel>
			</a4j:outputPanel>
		</h:form>
	</ui:define>
</ui:composition>
</html>